import type { App } from 'vue'

import useMainStore from '@/stores/modules/main'

/**
 * @method 自定义权限指令
 * @param app 全局app对象
 */
export default function (app: App) {
  app.directive('permission', {
    mounted(el: HTMLElement, binding) {
      const mainStore = useMainStore()
      if (!mainStore.permission?.includes(binding.value)) {
        el.style.display = 'none'
      }
    },
  })
}
